﻿using System;
using System.Web.Mvc;
using JML.Web.Views;

namespace JML.Web.Controllers
{
    public abstract class ControllerBase : Controller
    {
        private SmartBag _smartBag;


        public virtual SmartBag SmartBag
        {
            get
            {
                if (_smartBag == null)
                {
                    _smartBag = new SmartBag();
                }
                return _smartBag;
            }
        }


        protected new void RenderView(string viewName)
        {
            RenderView(viewName, String.Empty, null);
        }

        protected new void RenderView(string viewName, string masterName)
        {
            RenderView(viewName, masterName, null);
        }

        protected override void RenderView(string viewName, string masterName, object viewData)
        {
            //if they passed in view data, use that. Otherwise automatically pass in our SmartBag.
            if (viewData == null)
                viewData = SmartBag;

            base.RenderView(viewName, masterName, viewData);
        }
    }
}